#if !defined(__BUS_H__)
#define __BUS_H__

#include "stdint.h"

typedef struct bus_fun_param_item
{
    char *name;   /* 参数名称 */
    char *desc;   /* 参数描述 */
    uint8_t type; /* 参数类型 */
} bus_fun_param_item_s, *bus_fun_param_item_t;

typedef struct bus_fun_param_list
{
    uint8_t param_len;           /* 参数个数 */
    bus_fun_param_item_s list[]; /* 参数列表 */
} bus_fun_param_list_s, *bus_fun_param_list_t;

typedef struct bus_fun
{
    struct bus_fun *next;
    uint32_t id;                 /* 函数ID */
    char *name;                  /* 函数名称 */
    uintptr_t fn;                /* 函数接口 */
    bus_fun_param_list_t params; /* 函数参数列表 */
} bus_fun_s, *bus_fun_t;

typedef struct bus_state
{
    struct bus_state *next;
    uint32_t id;     /* 状态ID */
    uintptr_t value; /* 状态值 */
    char *name;      /* 名称 */
} bus_state_s, *bus_state_t;

typedef struct bus
{
    struct bus *next;
    uint32_t id;            /* 对象ID */
    char *name;             /* 对象名称 */
    bus_state_t state_list; /* 状态列表 */
    bus_fun_t fn_list;      /* 函数列表 */
} bus_s, *bus_t;

bus_t bus_create_obj(char *const name);
void bus_destroy_obj(bus_t bus);

bus_state_t bus_create_state(bus_t bus, char *name);
bus_fun_t bus_create_fn(bus_t bus, char *name, uintptr_t fn, bus_fun_param_list_t params);

#endif // __BUS_H__
